package com.chushouya.controller.manager.admin;


import com.chushouya.common.constant.ServiceType;
import com.general.framework.core.schema.Response;
import com.chushouya.manager.dto.admin.visitarea.VisitAreaDTO;
import com.chushouya.manager.dto.admin.visitarea.VisitAreaListDTO;
import com.chushouya.manager.dto.admin.visitarea.VisitAreaQuery;
import com.chushouya.manager.dto.admin.visitarea.VisitAreaSaveDTO;
import com.chushouya.manager.service.admin.VisitAreaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = ServiceType.PLATFORM + "上门区域管理")
@RestController
@RequestMapping(ServiceType.PLATFORM + "/visitArea")
public class VisitAreaController
{
    @Resource
    private VisitAreaService visitAreaService;

//    @Resource
//    private VisitAreaCacheService visitAreaCacheService;

    /**
     * 获取上门区域列表
     */
    @ApiOperation("获取上门区域列表")
    @GetMapping("/list")
    public Response<List<VisitAreaListDTO>> list(VisitAreaQuery visitAreaQuery) {
        visitAreaQuery.setPage(1);
        visitAreaQuery.setSize(1000);
        return Response.success(visitAreaService.selectVisitAreaList(visitAreaQuery));
    }

    /**
     * 获取上门区域详情
     */
    @ApiOperation("获取当前城市的上门区域")
    @GetMapping("/detail")
    public Response<VisitAreaDTO> detail(Long cityCode) {
        return Response.success(visitAreaService.selectVisitArea(cityCode));
    }

    /**
     * 保存上门区域
     */
    @ApiOperation("保存上门区域")
    @PostMapping("/save")
    public Response<Void> save(@RequestBody VisitAreaSaveDTO visitAreaDTO) {
        visitAreaService.saveVisitArea(visitAreaDTO);
        return Response.success();
    }

    /**
     * 删除上门区域缓存
     */
    @ApiOperation("删除上门区域缓存")
    @PostMapping("/refreshVisitAreaCache")
    public Response<Void> refreshVisitAreaCache() {
//        visitAreaCacheService.refreshVisitAreaCache();
        return Response.success();
    }


}
